﻿using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;

namespace YArchitech.Revit
{
	public class SprinklerOrAirTerminalFilter : ISelectionFilter
	{
		public SprinklerOrAirTerminalFilter(bool isSprinkler)
		{
			this.isSprinkler = isSprinkler;
		}

		public bool AllowElement(Element elem)
		{
			if (elem is FamilyInstance)
			{
				if (this.isSprinkler && ((FamilyInstance)elem).Category.Id.IntegerValue == -2008099)
				{
					return true;
				}
				if (!this.isSprinkler && ((FamilyInstance)elem).Category.Id.IntegerValue == -2008013)
				{
					return true;
				}
			}
			return false;
		}

		public bool AllowReference(Reference reference, XYZ position)
		{
			return false;
		}

		private bool isSprinkler = true;
	}
}
